#!/usr/bin/python3
# -*- coding: utf-8 -*-
import numpy as np


def signal(*args):

	df = args[0]
	n  = args[1]
	factor_name = args[2]

	df['该小时震幅'] = np.maximum(
		abs(df['high'] / df['open'] - 1),
		abs(df['low'] / df['open'] - 1)
	)
	df[factor_name] = df['该小时震幅'].rolling(n).max()

	return df
